﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace Sapro_Project
{
    public partial class PhonePageCadEsc : PhoneApplicationPage
    {
        public PhonePageCadEsc()
        {
            InitializeComponent();
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string nm;
            if (NavigationContext.QueryString.TryGetValue("nome", out nm)) {
                tb_esc_nome.Text = nm;
            }
        }
        private void bt_esc_conf_Click(object sender, RoutedEventArgs e)
        {
            try {
                Escola esc = new Escola();
                esc.Nome = tb_esc_nome.Text;
                esc.Telefone = Convert.ToInt32(tb_esc_telefone.Text);
                esc.Rua = tb_esc_rua.Text;
                esc.Numero = Convert.ToInt32(tb_esc_numero.Text);
                esc.Cep = Convert.ToInt32(tb_esc_cep.Text);
                Fachada.ObterFachada().CadastrarEscola(esc);
            }catch(Exception ex){
                MessageBox.Show("Não deu certo");
            }
        }
    }
}
